var t = require("../../../@babel/runtime/helpers/defineProperty"), a = require("../../../mycomponent/yz_pay/yz_pay"), e = getApp();

Page({
    behaviors: [ a ],
    data: {
        language: "",
        bannerindex: 1,
        mainCommentShow: !1,
        replyshow: !1,
        adminOperationshow: !1,
        adminOperationInfo: [],
        releaseOperationshow: !1,
        amountRewardshow: !1,
        rewardPayshow: !1,
        stickid: "",
        detailsData: {},
        StickCommentData: [],
        replyName: "",
        replyContent: "",
        host_comment_id: "",
        second_comment_id: "",
        maincomment: "",
        readertype: 1,
        is_praise: !0,
        rewardArr: [ {
            value: 1,
            name: "5"
        }, {
            value: 2,
            name: "10"
        }, {
            value: 3,
            name: "20"
        }, {
            value: 4,
            name: "50"
        }, {
            value: 5,
            name: "100"
        } ],
        rewardArrselect: 99999,
        rewardArrmoney: "",
        rewardArrmoneytype: 2,
        btnData: [],
        rewardMoney: 0,
        commentManagement: !1,
        is_own: !1,
        commend_id: "",
        mulcommentsshow: !0,
        Height: 0,
        LastHeight: 0,
        isLoadMore: !0,
        page: 1,
        total_page: 0,
        loading: !1,
        replyheight: 0,
        reward_button: 0,
        popupSpecs: !1,
        passwordInfo: {},
        pwds: [],
        pwd: "",
        pw1: "",
        pw2: "",
        pw3: "",
        pw4: "",
        pw5: "",
        pw6: ""
    },
    onLoad: function(t) {
        t.stickId ? this.data.stickid = t.stickId : wx.navigateBack({
            delta: 1
        }), this.getMicroDetails(), this.getCircleSet(), this.getStickComment();
    },
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        });
    },
    bindChangeBannerIndex: function(t) {
        this.setData({
            bannerindex: t.detail.current + 1
        });
    },
    onShow: function() {},
    adminBtn: function(a) {
        var i = this, n = a.currentTarget.dataset.type;
        if ("del" != n) if ("edit" != n) {
            console.log(n);
            var s = {
                circle_id: this.data.detailsData.circle_id,
                invitation_id: this.data.stickid,
                invitation_type: n
            }, o = e.getNetAddresss("plugin.circle.frontend.circle-invitation.set-invitation-review");
            e._postNetWork({
                url: o,
                showToastIn: !1,
                data: s,
                success: function(a) {
                    var s, o = a.data;
                    if (e.tips(o.msg), 1 == o.result) {
                        var r = 0;
                        0 == i.data.detailsData[n] && (r = 1);
                        var d = "detailsData." + n;
                        i.setData((t(s = {}, d, r), t(s, "adminOperationshow", !1), s));
                    }
                }
            });
        } else this.reEditBtn(); else this.deleteBtn();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.loading ? console.log("没有更多数据") : this.getMoreData();
    },
    onShareTimeline: function() {
        return {
            title: this.data.detailsData.title ? this.data.detailsData.title : ""
        };
    },
    onShareAppMessage: function() {
        return {
            title: this.data.detailsData.title ? this.data.detailsData.title : "",
            path: "/packageH/circleCommunity/topicDetails/topicDetails?stickId=" + this.data.stickid
        };
    },
    amountRewardshowbtn: function() {
        this.setData({
            amountRewardshow: !1
        });
    },
    getMicroDetails: function() {
        var t = this, a = {
            invitation_id: this.data.stickid
        }, i = e.getNetAddresss("plugin.circle.frontend.circle-invitation.details");
        e._postNetWork({
            url: i,
            showToastIn: !1,
            data: a,
            success: function(a) {
                var i = a.data;
                i.data.content && (i.data.content = i.data.content.replace(/(\r\n|\n|\r)/gm, "<br />")), 
                1 == i.result ? (t.setData({
                    detailsData: i.data
                }), t.data.detailsData && (1 == t.data.detailsData.is_master ? t.setData({
                    readertype: 3
                }) : 1 == t.data.detailsData.is_current_member && t.setData({
                    readertype: 2
                }), 1 == t.data.detailsData.is_manager ? t.setData({
                    is_praise: !0
                }) : t.setData({
                    is_praise: !1
                }))) : e.tips(i.msg);
            },
            fail: function(t) {}
        });
    },
    pageInit: function() {
        this.data.page = 1, this.data.total_page = 0, this.data.isLoadMore = !0, this.data.loading = !1;
    },
    getStickComment: function() {
        var t = this;
        this.pageInit();
        var a = {
            invitation_id: this.data.stickid
        }, i = e.getNetAddresss("plugin.circle.frontend.circle-invitation.get-comment-list");
        e._postNetWork({
            url: i,
            showToastIn: !1,
            data: a,
            success: function(a) {
                var e = a.data;
                1 == e.result ? (t.data.total_page = e.data.last_page, t.setData({
                    StickCommentData: e.data.data
                })) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {}
        });
    },
    gotoCart: function() {
        wx.reLaunch({
            url: "/packageG/index/index"
        });
    },
    toShop: function(t) {
        var a = t.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/packageC/o2o/o2oStore/o2oStore?store_id=" + a
        });
    },
    toGood: function(t) {
        var a = t.currentTarget.dataset.good_id;
        wx.navigateTo({
            url: "/packageA/detail_v2/detail_v2?id=" + a
        });
    },
    attentionBtn: function() {
        1 == this.data.detailsData.is_attention ? this.cancelAttention() : this.addAttention();
    },
    cancelAttention: function() {
        var t = this, a = {
            attention_member_id: this.data.detailsData.member_id
        }, i = e.getNetAddresss("plugin.circle.frontend.circle-member.cancel-attention");
        e._postNetWork({
            url: i,
            showToastIn: !1,
            data: a,
            success: function(a) {
                var i = a.data;
                e.tips(i.msg), 1 == i.result && t.setData({
                    "detailsData.is_attention": 0
                });
            },
            fail: function(t) {}
        });
    },
    addAttention: function() {
        var t = this, a = {
            attention_member_id: this.data.detailsData.member_id
        }, i = e.getNetAddresss("plugin.circle.frontend.circle-member.attention-member");
        e._postNetWork({
            url: i,
            showToastIn: !1,
            data: a,
            success: function(a) {
                var i = a.data;
                e.tips(i.msg), 1 == i.result && t.setData({
                    "detailsData.is_attention": 1
                });
            },
            fail: function(t) {}
        });
    },
    managementBtn: function() {
        var t = this.data.detailsData, a = [];
        1 == this.data.detailsData.is_master && (a = [ {
            type: "is_top",
            img: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/micro_communities/detail_roof@2x.png",
            name: 1 == t.is_top ? "取消置顶" : "置顶"
        }, {
            type: "is_recommend",
            img: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/micro_communities/detail_recommend@2x.png",
            name: 1 == t.is_recommend ? "取消推荐" : "推荐"
        }, {
            type: "is_show",
            img: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/micro_communities/detail_invisible@2x.png",
            name: 1 == t.is_show ? "取消未加入可见" : "未加入可见"
        } ]), 1 == this.data.detailsData.is_current_member && a.push({
            type: "edit",
            img: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/micro_communities/detail_revise@2x.png",
            name: "修改"
        }), a.push({
            type: "del",
            img: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/micro_communities/detail_delect@2x.png",
            name: "删除"
        }), this.setData({
            adminOperationInfo: a,
            adminOperationshow: !0
        });
    },
    replyCommentsBtn: function(t) {
        var a = t.currentTarget.dataset.hostcommentid, e = t.currentTarget.dataset.secondcommentid, i = t.currentTarget.dataset.uname, n = t.currentTarget.dataset.content, s = t.currentTarget.dataset.isown;
        this.setData({
            host_comment_id: a,
            second_comment_id: e,
            replyContent: "",
            replyName: i,
            replyshowcontent: n
        }), console.log(this.data.replyContent), 1 == s ? this.setData({
            is_own: !0
        }) : this.setData({
            is_own: !1
        }), this.setData({
            commentManagement: !0
        });
    },
    praiseBtn: function(t) {
        var a = t.currentTarget.dataset.hostcommentid, i = t.currentTarget.dataset.secondcommentid, n = t.currentTarget.dataset.index, s = t.currentTarget.dataset.chilindex;
        if (1 == t.currentTarget.dataset.ispraise) return e.tips("你已赞过该贴");
        this.getPraiseData(a, i, n, s);
    },
    getPraiseData: function(a, i, n, s) {
        var o = this, r = {}, d = e.getNetAddresss("plugin.circle.frontend.circle-invitation.comment-like");
        r.invitation_id = this.data.stickid, r.comment_id = a && i ? i : a, e._postNetWork({
            url: d,
            showToastIn: !1,
            data: r,
            success: function(r) {
                var d, c, m = r.data;
                (e.tips(m.msg), 1 == m.result) && (a && i ? o.setData((t(d = {}, "StickCommentData.[" + n + "].has_many_comment[" + s + "].is_like", 1), 
                t(d, "StickCommentData.[" + n + "].has_many_comment[" + s + "].link_count", o.data.StickCommentData[n].has_many_comment[s].link_count ? o.data.StickCommentData[n].has_many_comment[s].link_count + 1 : 1), 
                d)) : o.setData((t(c = {}, "StickCommentData[" + n + "].is_like", 1), t(c, "StickCommentData[" + n + "].link_count", o.data.StickCommentData[n].link_count ? o.data.StickCommentData[n].link_count + 1 : 1), 
                c)));
            },
            fail: function(t) {}
        });
    },
    mulchMeatsShowBtn: function() {
        this.setData({
            mulcommentsshow: !1
        }), this.getMoreData();
    },
    subMainCommentBtn: function() {
        this.setData({
            maincomment: "",
            mainCommentShow: !0
        });
    },
    moneyShow: function() {
        this.setData({
            rewardArrmoney: "",
            rewardArrselect: 9999,
            rewardMoney: 0,
            amountRewardshow: !0
        });
    },
    isPraiseBtn: function() {
        var t = this;
        if (1 == this.data.detailsData.is_like) return wx.showToast({
            icon: "none",
            title: "你已赞过该贴",
            duration: 1500
        }), !1;
        var a = e.getNetAddresss("plugin.circle.frontend.circle-invitation.like");
        e._postNetWork({
            url: a,
            showToastIn: !1,
            data: {
                invitation_id: this.data.stickid
            },
            success: function(a) {
                var i = a.data;
                e.tips(i.msg), 1 == i.result && t.setData({
                    "detailsData.likeCount": t.data.detailsData.likeCount ? t.data.detailsData.likeCount + 1 : 1
                });
            }
        });
    },
    subMainBtn: function() {
        this.data.maincomment ? (this.setData({
            mainCommentShow: !1
        }), this.getReplyComments("main")) : wx.showToast({
            icon: "none",
            title: "请输入你的精彩评论",
            duration: 1500
        });
    },
    getReplyComments: function(t) {
        var a = this, i = {}, n = e.getNetAddresss("plugin.circle.frontend.circle-invitation.comment");
        i.invitation_id = this.data.stickid, i.comment = "main" == t ? this.data.maincomment : this.data.replyContent, 
        "reply" == t && (this.data.host_comment_id && (i.parent_id = this.data.host_comment_id), 
        this.data.second_comment_id && (i.subordinate_id = this.data.second_comment_id)), 
        e._postNetWork({
            url: n,
            showToastIn: !1,
            data: i,
            success: function(t) {
                var e = t.data;
                1 == e.result ? (a.getStickComment(), wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                })) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {}
        });
    },
    replySubmitBtn: function() {
        this.data.replyContent ? (this.setData({
            replyshow: !1
        }), this.getReplyComments("reply")) : wx.showToast({
            icon: "none",
            title: "请输入回复内容",
            duration: 1500
        });
    },
    dminBtn: function(t) {
        var a = this, i = {};
        i.tid = a.stickid, 1 == t ? i.operation = 1 : 2 == t && (i.operation = 2);
        var n = e.getNetAddresss("plugin.micro-communities.api.trick.changeOperation");
        e._postNetWork({
            url: n,
            showToastIn: !1,
            data: i,
            success: function(t) {
                var e = t.data;
                e.result, a.setData({
                    adminOperationshow: !1
                }), wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {}
        });
    },
    deleteBtn: function() {
        var t = this, a = {}, i = e.getNetAddresss("plugin.circle.frontend.circle-invitation.del");
        a.invitation_id = t.data.stickid, e._postNetWork({
            url: i,
            showToastIn: !1,
            data: a,
            success: function(a) {
                var e = a.data;
                1 == e.result ? (wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                }), t.setData({
                    releaseOperationshow: !1,
                    adminOperationshow: !1
                }), wx.reLaunch({
                    url: "/packageH/circleCommunity/circleIndex/circleIndex"
                })) : (t.setData({
                    releaseOperationshow: !1,
                    adminOperationshow: !1
                }), wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                }));
            },
            fail: function(t) {}
        });
    },
    getCircleSet: function() {
        var t = this, a = e.getNetAddresss("plugin.circle.frontend.circle.get-set");
        e._getNetWork({
            url: a,
            data: {},
            success: function(a) {
                var i = a.data;
                if (1 != i.result) return e.tips(i.msg);
                t.setData({
                    reward_button: i.data.dashan
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    adCancel: function() {
        this.setData({
            adminOperationshow: !1
        });
    },
    reEditBtn: function() {
        wx.navigateTo({
            url: "/packageH/circleCommunity/circleTopic/circleTopic?stickId=" + this.data.stickid
        });
    },
    reCancelBtn: function() {
        this.setData({
            releaseOperationshow: !1
        });
    },
    shorewardArrBtn: function(t) {
        var a = t.currentTarget.dataset.index;
        this.setData({
            rewardArrmoneytype: 1,
            rewardArrselect: a,
            rewardArrmoney: ""
        });
    },
    confirmRewardBtn: function() {
        this.setData({
            amountRewardshow: !1
        }), console.log(this.data.rewardArrmoneytype), 1 == this.data.rewardArrmoneytype ? this.setData({
            rewardMoney: parseInt(this.data.rewardArr[this.data.rewardArrselect].name)
        }) : 2 == this.data.rewardArrmoneytype && this.setData({
            rewardMoney: this.data.rewardArrmoney
        }), e._isTextEmpty(this.data.rewardMoney) ? wx.showToast({
            icon: "none",
            title: "请输入或选择打赏金额",
            duration: 1500
        }) : this.data.rewardMoney <= 0 ? wx.showToast({
            icon: "none",
            title: "打赏金额必须大于0",
            duration: 1500
        }) : this.getPayData();
    },
    getPayData: function() {
        var t = this, a = e.getNetAddresss("plugin.circle.frontend.circle-pay.get-pay-button");
        e._getNetWork({
            url: a,
            success: function(a) {
                var e = a.data;
                if (1 == e.result) {
                    var i = e.data.buttons;
                    t.setData({
                        btnData: i,
                        rewardPayshow: !0
                    });
                }
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    payBtn: function(t) {
        var a, i, n = this, s = null;
        t.currentTarget ? (a = t.currentTarget.dataset.info.value, i = t.currentTarget.dataset.info.name, 
        s = t.currentTarget.dataset.info) : (a = t.value, i = t.name, s = t);
        var o = e.getNetAddresss("plugin.circle.frontend.circle-pay.invitation-reward"), r = {
            pay_method: a,
            price: this.data.rewardMoney,
            pay_name: i,
            invitation_id: this.data.stickid,
            client_type: "2"
        };
        e._postNetWork({
            url: o,
            showToastIn: !1,
            data: r,
            success: function(t) {
                var e = t.data;
                1 == e.result ? (n.setData({
                    rewardPayshow: !1
                }), n.handleOtherPay(s, a, e.data)) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            }
        });
    },
    rewardPayCancelBtn: function() {
        this.setData({
            rewardPayshow: !1
        });
    },
    replyBtn: function() {
        this.setData({
            replyshow: !0,
            commentManagement: !1
        });
    },
    delBtn: function() {
        this.data.host_comment_id && this.data.second_comment_id ? this.setData({
            commend_id: this.data.second_comment_id
        }) : this.setData({
            commend_id: this.data.host_comment_id
        }), this.setData({
            commentManagement: !1
        }), this.delReply();
    },
    delReply: function() {
        var t = this, a = {}, i = e.getNetAddresss("plugin.circle.frontend.circle-invitation.delete-comment");
        a.comment_id = this.data.commend_id, e._postNetWork({
            url: i,
            showToastIn: !1,
            data: a,
            success: function(a) {
                var e = a.data;
                1 == e.result ? (t.getStickComment(), wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                })) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {}
        });
    },
    replyCancelBtn: function() {
        this.setData({
            commentManagement: !1
        });
    },
    imgHeight: function(t) {
        var a = wx.getSystemInfoSync().windowWidth * t.detail.height / t.detail.width + "px";
        parseInt(a) > this.data.LastHeight && (this.setData({
            Height: a
        }), this.data.LastHeight = parseInt(a));
    },
    maincommentinp: function(t) {
        var a = t.detail.value;
        this.setData({
            maincomment: a
        });
    },
    rewardArrmoneyinp: function(t) {
        var a = t.detail.value;
        this.setData({
            rewardArrmoney: a
        });
    },
    replyContentinp: function(t) {
        var a = t.detail.value;
        this.setData({
            replyContent: a
        });
    },
    replyfocus: function(t) {
        var a = t.detail.height;
        this.setData({
            replyheight: a
        });
    },
    replyblur: function(t) {
        this.setData({
            replyheight: 0
        });
    },
    replyshowClose: function() {
        this.setData({
            replyshow: !1
        });
    },
    mainCommentShowClose: function() {
        this.setData({
            mainCommentShow: !1
        });
    },
    adminOperationshowClose: function() {
        this.setData({
            adminOperationshow: !1
        });
    },
    releaseOperationshowClose: function() {
        this.setData({
            releaseOperationshow: !1
        });
    },
    amountRewardshowClose: function() {
        this.setData({
            amountRewardshow: !1
        });
    },
    rewardPayshowClose: function() {
        this.setData({
            rewardPayshow: !1
        });
    },
    commentManagementClose: function() {
        this.setData({
            commentManagement: !1
        });
    },
    getMoreData: function() {
        var t = this;
        if (this.data.mulcommentsshow) return !1;
        var a = {
            invitation_id: this.data.stickid
        };
        this.data.isLoadMore = !1;
        var i = e.getNetAddresss("plugin.circle.frontend.circle-invitation.get-comment-list");
        this.data.page >= this.data.total_page ? this.setData({
            loading: !0
        }) : (this.data.page = this.data.page + 1, a.page = this.data.page, e._postNetWork({
            url: i,
            showToastIn: !1,
            data: a,
            success: function(a) {
                var e = a.data;
                if (1 == e.result) {
                    var i = e.data.data;
                    t.setData({
                        StickCommentData: t.data.StickCommentData.concat(i)
                    });
                } else t.data.page = t.data.page - 1, t.data.isLoadMore = !1;
            },
            fail: function(t) {}
        }));
    }
});